package com.open.cloud.uid.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * @author leijian
 * @version 1.0
 * @date 2019/3/31 20:15
 **/
public class BusiUtil {

    public static boolean isNotNull(Object obj) {
        return !isNull(obj);
    }

    public static boolean isNull(Object obj) {
        return isNullObj(obj);
    }

    private static boolean isNullObj(Object obj) {
        if (obj == null) {
            return true;
        }
        if (String.class.isInstance(obj)) {
            return StringUtils.isEmpty((String) obj);
        } else if (List.class.isInstance(obj)) {
            return ((List) obj).isEmpty();
        } else if (Map.class.isInstance(obj)) {
            return ((Map) obj).size() == 0;
        } else {
            return obj == null;
        }
    }

}
